package com.sc.service.consultComment;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sc.dal.mapper.consultComment.ConsultCommentMapper;
import com.sc.dal.model.consultComment.ConsultComment;
import com.sc.service.BaseServiceImpl;

@Service
public class ConsultCommentService extends BaseServiceImpl<Map<String, Object>>{

	@Autowired
	private ConsultCommentMapper consultCommentMapper;
	
	public int insertByConsultComment(ConsultComment record){
		return consultCommentMapper.insertSelective(record);
	}
	
	public List<ConsultComment> queryMessageList(Map<String, Object> paramMap){
//		List<ConsultComment> list = consultCommentMapper.selectByPageView(paramMap);
		List<ConsultComment> list = consultCommentMapper.select(paramMap);
		return list;
	}
	
	public List<ConsultComment> queryLatelyTracks(Map<String, Object> paramMap){
		List<ConsultComment> list = consultCommentMapper.queryLatelyTracks(paramMap);
		return list;
	}
	
	/**
	 * 根据id查询信息
	 * @param id
	 * @return
	 */
	public ConsultComment findMessageReplyById(Integer id){
		return consultCommentMapper.selectByPrimaryKey(id);
	}
	
	public int updateMessageReply(ConsultComment record){
		return consultCommentMapper.updateByPrimaryKeySelective(record);
	}
	
	/***
	 * 咨询详情信息
	 * @param paramMap
	 * @return
	 */
	public ConsultComment selectConsultDetail(Integer id){
		return consultCommentMapper.selectByPrimaryKey(id);
	}
	
	public List<String> findConsultByGoodsId(Integer id){
		return consultCommentMapper.findConsultByGoodsId(id);
	}
	public List<String> findConsultByCreater(Map<String, Object> idMap){
		return consultCommentMapper.findConsultByCreater(idMap);
	}
	
	/**
	 * 根据ID删除足迹信息
	 * @param id
	 * @return
	 */
	/*public int deleteConsultAll(Map<String, Object> parmMap){
		return consultCommentMapper.deleteByPrimaryKeyAll(parmMap);
	}*/
	/**
	 * 根据ID删除足迹信息
	 * @param id
	 * @return
	 */
	public int deleteConsult(Integer id){
		return consultCommentMapper.deleteByPrimaryKey(id);
	}
	
	 /***
     * 根据ID查询包含的子级
     * @param map
     * @return
     */
	public List<ConsultComment> selectParentList(Map<String, Object> map){
		return consultCommentMapper.selectParentList(map);
	}
	
	/**
	 * 查询订单中的某商品的初次评价信息
	 */
	public ConsultComment selectParentConsultComment(ConsultComment comment){
		return consultCommentMapper.selectParentConsultComment(comment);
	}
	/**
	 * 根据商品ID和订单ID查询订单评论列表
	 * @param id
	 * @return
	 */
	public List<ConsultComment> selectCommentByParam(ConsultComment comment){
		return consultCommentMapper.selectCommentByParam(comment);
	}

	public int updateByPrimaryKeySelective(ConsultComment record) {
	   return consultCommentMapper.updateByPrimaryKeySelective(record);
	}
	
	public List<String> findIsComment(String orderId,Integer goodsId){
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("orderId", orderId);
		map.put("goodsId", goodsId);
		return consultCommentMapper.findIsComment(map);
	}
	
}
